package com.atguigu.tingshu.album.mapper;

import com.atguigu.tingshu.model.album.AlbumStat;
import com.atguigu.tingshu.vo.album.AlbumStatVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AlbumStatMapper extends BaseMapper<AlbumStat> {


    @Select("select\n" +
            "    stat.album_id,\n" +
            "    max(if(stat.stat_type = '0401', stat.stat_num, 0)) playStatNum,\n" +
            "    max(if(stat.stat_type = '0402', stat.stat_num, 0)) subscribeStatNum,\n" +
            "    max(if(stat.stat_type = '0403', stat.stat_num, 0)) buyStatNum,\n" +
            "    max(if(stat.stat_type = '0404', stat.stat_num, 0)) commentStatNum\n" +
            "    from album_stat stat where stat.album_id=1200\n" +
            "group by album_id\n" +
            "order by album_id desc;")
    AlbumStatVo selectAlbumStatVo(Long albumId);
}
